//
//  ViewController.m
//  LBLoopScrollView
//
//  Created by LINAICAI on 2017/6/5.
//  Copyright © 2017年 LINAICAI. All rights reserved.
//

#import "ViewController.h"
#import "LBLoopScrollView.h"
#import "LBTestLoopSubView.h"
#import "VerticalViewController.h"
#import "UIPageControl+LBLoopScrollView.h"
#import <Masonry/Masonry.h>
@interface ViewController ()
@property(nonatomic , strong)LBTestLoopSubView *leftAdView;
@property(nonatomic , strong)LBLoopScrollView *rightAdView;

@end

@implementation ViewController
- (LBTestLoopSubView *)leftAdView{
    if (!_leftAdView) {
        LBTestLoopSubView *view = [[LBTestLoopSubView alloc]initWithimages:@[@"http://wallpaper-for-ios.qiniudn.com/BeautyGirl@3x.png",
                                                                             @"http://wallpaper-for-ios.qiniudn.com/Landscape@3x.png",
                                                                             @"http://wallpaper-for-ios.qiniudn.com/Creative@3x.png",
                                                                             @"http://wallpaper-for-ios.qiniudn.com/dm.jpg"
                                                                             ]];
        view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width*9/16);
        view.automatically = YES;
        view.direction = LBLoopScrollViewDirectionLeft;
        view.showPageControl = YES;
        view.timeInterval = 1.0;
        _leftAdView = view;
    }
    return _leftAdView;
}
- (LBLoopScrollView *)rightAdView{
    if (!_rightAdView) {
        LBLoopScrollView *view = [[LBLoopScrollView alloc]initWithimages:@[@"http://wallpaper-for-ios.qiniudn.com/BeautyGirl@3x.png",
                                                                           @"http://wallpaper-for-ios.qiniudn.com/Landscape@3x.png",
                                                                           @"http://wallpaper-for-ios.qiniudn.com/Creative@3x.png",
                                                                           @"http://wallpaper-for-ios.qiniudn.com/dm.jpg"
                                                                           ]];
        view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width*9/16);

        view.backgroundColor = [UIColor whiteColor];
        view.automatically = YES;
        view.direction = LBLoopScrollViewDirectionRight;
        view.showPageControl = YES;
        view.timeInterval = 1.0;
        _rightAdView = view;
    }
    return _rightAdView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    [self.navigationController.navigationBar setBackgroundColor:[UIColor whiteColor]];
    
    
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    [tableView setDelegate:(id<UITableViewDelegate> _Nullable)self];
    [tableView setDataSource:(id<UITableViewDataSource> _Nullable)self];
    tableView.tableHeaderView = self.leftAdView;
    tableView.tableFooterView = self.rightAdView;
    
    [self.view addSubview:tableView];






    // Do any additional setup after loading the view, typically from a nib.
}

//轮播组件点击回调
- (void)LBLoopScrollViewDidClickWithIndex:(NSInteger)index{
    NSLog(@"点击了广告:%ld",(long)index);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identity"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"identity"];
    }
    cell.textLabel.text = @"分割线";
    return cell;
}

@end
